<template>
  <div class="content">
    <img class="logo" src="../assets/image/logo.png" alt="" />
    <div class="area">
      <i class="icon4 icon_area"></i>
      <label>深圳</label>
      <i class="icon4 icon_jtd"></i>
    </div>
    <el-input
      v-model="input"
      placeholder="请输入医院、医生、疾病等"
      class="search"
    >
      <template #prepend>
        <i class="icon4 icon_search"></i>
      </template>
      <template #append>
        <el-button class="search_btn">搜索</el-button>
      </template>
    </el-input>
    <div class="header_right">
      <div class="fLogin">
        <el-dropdown>
          <span class="el-dropdown-link box">
            <i class="icon4 icon_zh"></i>登录
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item
                class="drop"
                divided
                v-for="item in dropdownList"
                :key="item.name"
                @click="doLogin(item.Key)"
                >{{ item.name }}</el-dropdown-item
              >
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <div class="box"><i class="icon4 icon_zc"></i>注册</div>
      </div>
    </div>
  </div>

  <el-dialog append-to-body class="loginDialog" v-model="loginVisible" width="350" draggable>
    <template #header>
      <div class="login_title">
        {{ loginTitle }}
      </div>
    </template>
    <div class="con">
      <div class="login_tit">
        <div>用户登录</div>
        <div>
          还不是会员?
          <span class="mouse_over">立即注册</span>
        </div>
      </div>
      <div class="form">
        <el-form class="form">
          <el-form-item>
            <el-input
              placeholder="手机号、身份证号、会员卡号"
              v-model="loginForm.username"
              :prefix-icon="User"
              size="large"
            ></el-input>
          </el-form-item>
          <el-form-item class="margb12">
            <el-input
              placeholder="密码"
              v-model="loginForm.password"
              :prefix-icon="Unlock"
            ></el-input>
          </el-form-item>
          <el-form-item class="margb12">
            <el-checkbox v-model="loginForm.auto"> 下次自动登录 </el-checkbox>
            <span class="lose mouse_over">忘记密码?</span>
          </el-form-item>
          <el-form-item>
            <div class="loginBtn mouse_over2">登录</div>
          </el-form-item>
          <div class="three">
            <div>第三方合作账号登录：</div>
            <div>
              <span
                v-for="item in threeList"
                @mouseover="item.flag = !item.flag"
                @mouseout="item.flag = !item.flag"
                :style="{
                  'background-position': `${
                    item.flag ? item.position : item.positionHov
                  }`,
                }"
              ></span>
            </div>
          </div>
          <div class="agree">
            <div class="curr" @click="loginForm.agree = !loginForm.agree">
              <el-icon v-if="loginForm.agree" class="icon"
                ><CircleCheckFilled
              /></el-icon>
            </div>
            已阅读并同意
            <span>《健康之路用户注册协议》</span>
            <span>《健康之路产品隐私政策》</span>
            <span>《健康之路儿童个人信息保护规则》</span>
            <span>《健康之路用户自律公约》</span>
          </div>
        </el-form>
      </div>
    </div>
  </el-dialog>
</template>

<script lang="ts" setup>
import { useRouter, useRoute } from "vue-router";
import { computed, onMounted, reactive, ref, watch } from "vue";
import { useStore } from "vuex";
import { ElMessage } from "element-plus";
import { Unlock, User } from "@element-plus/icons-vue";

const threeList = ref([
  { flag: false, position: "0px 0", positionHov: "0px -20px" },
  { flag: false, position: "-20px 0", positionHov: "-20px -20px" },
  { flag: false, position: "-40px 0", positionHov: "-40px -20px" },
  { flag: false, position: "-60px 0", positionHov: "-60px -20px" },
  { flag: false, position: "-80px 0", positionHov: "-80px -20px" },
]);
const input = ref("");

const dropdownList = [
  { name: "用户登录", Key: 1 },
  { name: "医生登录", Key: 2 },
  { name: "医院登录", Key: 3 },
];
const loginVisible = ref(false);

const loginTitle = ref("您尚未登录");
function doLogin(key: number) {
  loginVisible.value = true;
}
const loginForm = reactive({
  username: "",
  password: "",
  auto: false,
  agree: false,
});
</script>
<style lang="less" scoped>
.loginDialog {
  .login_title {
    font-size: 16px;
    font-weight: bold;
    color: #3d3d3d;
    text-align: left;
    border-bottom: #f2f2f2 1px solid;
    height: 40px;
    line-height: 30px;
  }
  .con {
    color: #222222;
    .login_tit {
      height: 40px;
      line-height: 24px;
      display: flex;
      justify-content: space-between;
      padding: 0 8px;
      > div:nth-child(1) {
        font-size: 16px;
      }
      > div:nth-child(2) {
        font-size: 14px;
        color: #aeaeae;
        span {
          color: #007cd9;
          margin-left: 4px;
        }
      }
    }
    .form {
      width: 290px;
      margin-left: 8px;
      .el-input {
        height: 42px;
      }

      :deep(.el-input .el-input__icon) {
        width: 20px;
      }

      :deep(.el-icon svg) {
        height: 20px;
        width: 20px;
        font-size: 18px;
      }
      .lose {
        margin-left: 110px;
      }
      .loginBtn {
        width: 290px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        background-color: #3cc14d;
        color: #fff;
      }
      .margb12 {
        margin-bottom: 12px;
      }
      .three {
        text-align: left;
        font-size: 12px;
        padding: 0 8px;
        height: 20px;
        line-height: 20px;
        display: flex;
        span {
          display: inline-block;
          width: 20px;
          height: 20px;
          background: url(../assets/image/wdt-social-icon.jpg) no-repeat;
          overflow: hidden;
          margin-right: 10px;
          cursor: pointer;
          transition: all 0.3s ease;
        }
      }
      .agree {
        margin-top: 10px;
        padding: 0 8px;
        font-size: 12px;
        text-align: left;
        line-height: 22px;
        .curr {
          height: 18px;
          width: 18px;
          border-radius: 50%;
          border: 1px solid #aeaeae;
          display: inline-block;
          transform: translateY(4px);
          margin-right: 4px;
          .icon {
            height: 18px;
            width: 18px;
            color: #2acf8d;
          }
        }
        color: #aeaeae;
        span{
          color: #5e6b7a;
          cursor: pointer;
        }
      }
    }
  }
}
.content {
  height: 120px;
  width: 1200px;
  display: flex;
  align-items: center;
  background-color: #fff;
  .logo {
    width: 205px;
    height: 77px;
  }
  .area {
    width: 78px;
    height: 27px;
    margin-left: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    .icon_area {
      height: 100%;
      width: 17px;
      background-position: -60px -40px;
    }
    .icon_jtd {
      width: 12px;
      height: 7px;
      background-position: -80px -40px;
    }
  }
  .search {
    width: 500px;
    height: 46px;
    margin-left: 30px;
    .icon_search {
      width: 22px;
      height: 22px;
      background-position: -100px -40px;
    }
    :deep(.el-input-group__prepend) {
      background-color: #fff;
      padding: 0 14px;
    }
    .search_btn {
      width: 120px;
      color: #fff;
      font-size: 16px;
      background-color: #2acf8d;
      height: 100%;
      &:hover {
        background-color: #6ce0b1;
      }
    }
    :deep(.el-button) {
      border-top-left-radius: 0%;
      border-bottom-left-radius: 0%;
    }
  }
  .header_right {
    margin-left: 50px;
    .fLogin {
      height: 66px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .box {
        color: #2acf8d;
        font-size: 16px;
        line-height: 28px;
        display: flex;
        align-items: center;
        cursor: pointer;
      }
      .icon_zh {
        width: 18px;
        height: 18px;
        background-position: -130px -40px;
        margin-right: 6px;
      }
      .icon_zc {
        width: 18px;
        height: 18px;
        background-position: -150px -40px;
        margin-right: 6px;
      }
    }
  }
}
</style>
